/*
 * Ext JS Library 1.0
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

// create the HelloWorld application (single instance)
var PopupWindow = function(){
    // everything in this space is private and only accessible in the PopupWindow block
    
    // define some private variables
    var dialog, showBtn;
    
    // return a public interface
    return {
        init : function(){
             showBtn = Ext.get('show-popup-btn');
             // attach to click event
             showBtn.on('click', this.showDialog, this);
        },
       
        showDialog : function(){
            if(!dialog){ // lazy initialize the dialog and only create it once
                dialog = new Ext.BasicDialog("popupWindowContent", { 
                        autoTabs:true,
                        width:952,
                        height:340,
                        shadow:true,
                        minWidth:800,
                        minHeight:600,
                        proxyDrag: true
                });
                dialog.addKeyListener(27, dialog.hide, dialog);
                dialog.addButton('Cerrar', dialog.hide, dialog);
            }
            dialog.show(showBtn.dom);
        }
    };
}();

// using onDocumentReady instead of window.onload initializes the application
// when the DOM is ready, without waiting for images and other resources to load
Ext.onReady(PopupWindow.init, PopupWindow, true);